#pragma once
#ifndef LANDMARK_H
#define LANDMARK_H

#include "common_include.h"
#include"feature_point.h"

namespace test_visual_odom{

struct Frame;
struct FeaturePoint;

struct LandMark{
    public:
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
    typedef shared_ptr<LandMark> Ptr;
    unsigned long id_ = 0;
    bool is_outlier_ = false;
    Eigen::Vector3d pos_world_ = Eigen::Vector3d::Zero();
    mutex data_mutex_;
    list<weak_ptr<FeaturePoint>> feature_points2D_;  //不同帧可能同时观测到同一个landmark，就出现不同的2D特征点
    int observed_times_ =0;  //方便后端处理是否删除当前landmark

    LandMark() {}

    static LandMark::Ptr createNewLandmark();  //因为有静态变量，函数设置为static

    void setPos(const Eigen::Vector3d &pos){
        unique_lock<mutex> lock(data_mutex_);
        pos_world_ = pos; 
    }

    void addFeaturePoint2D(shared_ptr<FeaturePoint> feature_point2D){
        unique_lock<mutex> lock(data_mutex_);
        feature_points2D_.push_back(feature_point2D);
        observed_times_++;
    }

    void removeFeaturePoint2D(shared_ptr<FeaturePoint> feat); 
};


}
#endif  